<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <script>
        var tiezi = ['马上元旦了', '刘', '中午就可以放假了', '2023-12-29']
        // 对象声明
        var obj = {
            dianzan: 100,
            title: '马上元旦了',
            author: '刘',
            content: '中午就可以放假了',
            time: '2023-12-29',
            sayTitle: function(){
                console.log(obj.title)
            }
        }
        for(var key in obj){
            console.log(typeof obj[key])
            if(typeof obj[key] == 'string'|| typeof obj[key] == 'number'){
                document.write(
                    '<li>'+key+':'+obj[key]+'</li>'
                )
            }
        }
        // 对象的访问
        console.log(obj.title)
        console.log(obj['title'])
        obj.sayTitle();

        var key = 'time'
        console.log(obj.key);//undefined，.后面不能放变量
        console.log(obj[key]);//[]内可以放变量
    </script>
</body>
</html>